import Api from './api'

class TaskApi extends Api {
  getMyTasks (data) {
    return this.request({
      url: `${this.servicePath}/${this.modulePath}/myTask`,
      method: 'post',
      data
    })
  }

  produce (taskId) {
    return this.request({
      url: `${this.servicePath}/${this.modulePath}/produce/${taskId}`,
      method: 'put'
    })
  }

  cancel (taskId) {
    return this.request({
      url: `${this.servicePath}/${this.modulePath}/cancel/${taskId}`,
      method: 'put'
    })
  }

  finish (taskId) {
    return this.request({
      url: `${this.servicePath}/${this.modulePath}/finish/${taskId}`,
      method: 'put'
    })
  }

  getTaskByOrder (orderId) {
    return this.request({
      url: `${this.servicePath}/${this.modulePath}/order/${orderId}`,
      method: 'get'
    })
  }
}

export default new TaskApi('factory/task')
